<script type="text/javascript">
			var g_datacustomer;
		
			function openPopupCustomer(){
				resetCustomer();
				openPopup("popupCustomer",function(){});
			}

			function resetCustomer(){
				g_datacustomer = null;
				jQuery("#pCifNo").val("");
				jQuery("#pCustomerName").val("");
				
				var tableCustomer = jQuery("#tableCustomer");

				jQuery("#tableCustomer tbody").remove();

				tableCustomer.append('<tr><th align="center">No.</th><th align="center">CIF No.</th><th align="center">Customer Name</th><th align="center">Margin A/C No.</th><th align="center">Margin A/C Name</th></tr>');
			}

			function searchCustomer(){
				alert("search!!!");
				var tableCustomer = jQuery("#tableCustomer");
			
				jQuery("#tableCustomer tbody").remove();
			
				tableCustomer.append('<tr><th align="center">No.</th><th align="center">CIF No.</th><th align="center">Customer Name</th><th align="center">Margin A/C No.</th><th align="center">Margin A/C Name</th></tr>');
							
				var cifNo 		 = jQuery("#pCifNo").val();
				var customerName = jQuery("#pCustomerName").val();
				loading();
				
				jQuery.post("/FxMargin/DepositWithdrawServlet",{
						"rowVersion" 		: "1",
						"cifNo"				: cifNo,
						"customerName"		: customerName,
						"action"			: "searchCustomer"
					},
					function(data){
						rs = data.data;
			
						for(var i = 0 ; i < rs.length ; i++){
							var table = "<tr  >";
			
							table += "<td align='center'>" + "<input type='radio' name='data' id='r" + i + "' onclick='onSelectData(" + JSON.stringify(rs[i]) + ");' />" + "</td>";
							table += "<td align='center'>" + rs[i].cifNo + "</td>";
							table += "<td align='center'>" + rs[i].customerName + "</td>";
							table += "<td align='center'>" + formatMarginAccNo(rs[i].marginAccNo) + "</td>";
							table += "<td align='center'>" + rs[i].marginAccName + "</td>";
							table += "</tr>";
			
							tableCustomer.append(table);
						}
						
						unloading();
					},"json").error(
					function(){
						unloading();
						alert("Ajax error");
					}
				);
			}
			
			function onSelectData(data){			
				g_datacustomer = data;
			}

			function formatMarginAccNo(marginAccNo){
				var result = null;
				
				if(marginAccNo != null && marginAccNo != ""){
					marginAccNo = lpad(marginAccNo,10,"0");

					result = "";
					for(var i=0; i<marginAccNo.length; i++){
						if(i==3 || i==4 || i==9){
							result += "-" +tmp.charAt(i);
						}else{
							result += tmp.charAt(i);
						}
					}
				
				}else{
					result = marginAccNo+"";
				}
				
				return result;
			}

			function lpad(content,padLength,padChar)
			{
				content += "";

				//Length
			 	if(content.length > padLength){
					content = content.substring(0,padLength)
			 	}

			 	for(var i=content.length; i<padLength; i++){
					content = padChar + content;
			 	}
			 	
			 	return content;
			}
		</script>
		    
    	<div style="display:none">
       		<div id="popupCustomer" style="width:600px;height:400px;">
       			<center>
       				<div style="width:95%" align="center">
			        	<table width="100%" class="MarginHeader">
							<tr>
								<td align="left">Customer Information</td>
							</tr>
						</table>
		        		<table width="100%" class="MarginCriteria">
							<tr>
								<td width="50%" align="right">CIF No. :</td>
								<td width="50%" align="left" ><input type="text" id="pCifNo"/></td>
							</tr>
							<tr>
								<td width="50%" align="right">Customer Name :</td>
								<td width="50%" align="left" ><input type="text" id="pCustomerName"/></td>
							</tr>			
						</table>
					
						<table width="100%">
							<tr>
								<td width="50%" align="center"><input type="button" value="Search" class="button" onclick="searchCustomer();"/></td>
								<td width="50%" align="center"><input type="button" value="Reset" class="button" onclick="resetCustomer();"/></td>
							</tr>
						</table>
					
						<div class="MarginTable" style="overflow-y: scroll;height: 200px;">
							<table width="100%" id="tableCustomer" style="height: 20px">
								<tr>
									<th align="center">No.</th>
									<th align="center">CIF No.</th>
									<th align="center">Customer Name</th>
									<th align="center">Margin A/C No</th>
									<th align="center">Margin A/C Name</th>
								</tr>
							</table>
						</div>
						
						<table width="100%">
							<tr>
								<td width="33%" align="center">
									<input type="button" value="Ok" class="button" onclick="onCustomer();"/>
								</td>
								<td width="34%" align="center">
									<input type="button" value="Close" class="button" onclick="offCustomer();"/>
								</td>
							</tr>
						</table>
					</div>
       			</center>
	        </div>
	    </div>